<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/4/23
 * Time: 14:20
 */

namespace app\controller\index\oversea;


use app\controller\index\BaseController;
use app\exception\IndexException;
use app\logic\index\article\ArticleLogic;
use app\logic\index\oversea\OverseaLogic;
use app\logic\index\plan\PlanLogic;
use support\Request;
use support\Response;

class IndexController extends BaseController
{
    public function submitData(Request $request):Response
    {
        $param = [];
        $param['content'] = $request->input('content');
        $param['musicid'] = $request->input('musicid');
        $param['timbreid'] = $request->input('timbreid');
        $param['music_volume'] = $request->input('music_volume');
        $param['timbre_volume'] = $request->input('timbre_volume');
        $param['speak_speed'] = $request->input('speak_speed');
        $param['fontid'] = $request->input('fontid');
        $param['video_rate'] = $request->input('video_rate');
        $param['material_id'] = $request->input('material_id');
        $param['local_video'] = $request->input('local_video');
        $param['settings'] = $request->input('settings');
        $param['font_size'] = $request->input('font_size');
        $param['caption_post_x'] = $request->input('caption_post_x');
        $param['caption_post_y'] = $request->input('caption_post_y');

        //2024-09-18优化迭代
        $param['style_type'] = $request->input('style_type'); /*风格列表中的type*/
        $param['chat_images'] = $request->input('chat_images');/*聊天框的图片数组*/
        $param['chat_messages'] = $request->input('chat_messages');/*内容图片数组*/
        $param['card_image'] = $request->input('card_image');/*卡片图片地址*/
        $param['card_remain'] = $request->input('card_remain');/*卡片停留时长(秒)*/
        $param['card_top'] = $request->input('card_top');/*卡片顶部距离百分比(秒)*/
        $param['card_content'] = $request->input('card_content');/*卡片内容*/

        if(empty($param['content'])){
            throw new IndexException(4020,'文章内容不存在');
        }
        if(empty($param['timbreid'])){
            throw new IndexException(4020,'配音必选');
        }
        if(empty($param['material_id']) && empty($param['local_video'])){
            throw new IndexException(4020,'素材至少选择一个方式');
        }
        $data = OverseaLogic::getInstance()->submitData($param);

        return $this->endSuccess($data);
    }

    public function submitDataByOverseaNovel(Request $request):Response
    {
        $param = [];
        $param['novel_sn'] = $request->input('novel_sn');
        $param['id'] = $request->input('id');
		

        if(empty($param['novel_sn'])){
            throw new IndexException(4020,'推文不存在');
        }

        $data = OverseaLogic::getInstance()->submitDataByOverseaNovel($param);

        return $this->endSuccess($data);
    }

    public function getPlanList(Request $request):Response
    {
        $param = [];
        $param['lang'] = $request->input('lang');

        $data = OverseaLogic::getInstance()->getPlanList($param);

        return $this->endSuccess($data);
    }

}